﻿using System.ComponentModel;
using LiveTiss.Classes;
using System.Collections.Generic;

namespace LiveTiss.Schemas
{
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.ans.gov.br/padroes/tiss/schemas")]
    public partial class ct_guiaResumoInternacao : IDataErrorInfo
    {
        #region Public Properties - Custom

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public System.DateTime? _dataHoraInternacao
        {
            get
            {
                if (dataHoraInternacaoField > Util.EmptyDate)
                    return this.dataHoraInternacaoField;
                else
                    return null;
            }
            set
            {
                if (value.HasValue)
                {
                    if ((object.ReferenceEquals(this.dataHoraInternacaoField, value.Value) != true))
                    {
                        this.dataHoraInternacaoField = value.Value;
                        this.OnPropertyChanged("dataHoraInternacao");
                    }
                }
                else
                {
                    if ((object.ReferenceEquals(this.dataHoraInternacaoField, Util.EmptyDate) != true))
                    {
                        this.dataHoraInternacaoField = Util.EmptyDate;
                        this.OnPropertyChanged("dataHoraInternacao");
                    }
                }
            }
        }

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public System.DateTime? _dataHoraSaidaInternacao
        {
            get
            {
                if (dataHoraSaidaInternacaoFieldSpecified && dataHoraSaidaInternacaoField > Util.EmptyDate)
                    return this.dataHoraSaidaInternacaoField;
                else
                    return null;
            }
            set
            {
                if (value.HasValue)
                {
                    dataHoraSaidaInternacaoFieldSpecified = true;
                    if ((object.ReferenceEquals(this.dataHoraSaidaInternacaoField, value.Value) != true))
                    {
                        this.dataHoraSaidaInternacaoField = value.Value;
                        this.OnPropertyChanged("dataHoraSaidaInternacao");
                    }
                }
                else
                {
                    dataHoraSaidaInternacaoFieldSpecified = false;
                    if ((object.ReferenceEquals(this.dataHoraSaidaInternacaoField, Util.EmptyDate) != true))
                    {
                        this.dataHoraSaidaInternacaoField = Util.EmptyDate;
                        this.OnPropertyChanged("dataHoraSaidaInternacao");
                    }
                }
            }
        }

        // st_eletivaEmergencia
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> caraterInternacaoItems
        {
            get
            {
                return XML_enum.EletivaEmergencia;
            }
        }

        // st_tipoAcomodacao
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> acomodacaoItems
        {
            get
            {
                return XML_enum.TipoAcomodacao;
            }
        }

        // st_tipoInternacao
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> tipoInternacaoItems
        {
            get
            {
                return XML_enum.TipoInternacao;
            }
        }

        // st_regimeInternacao
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> regimeInternacaoItems
        {
            get
            {
                return XML_enum.RegimeInternacao;
            }
        }

        #endregion

        #region IDataErrorInfo

        private string _error = null;
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public string Error { get { return _error; } }

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public string this[string propertyName]
        {
            get
            {
                _error = null;
                switch (propertyName)
                {
                    case "dataHoraInternacao":
                        if (this.dataHoraInternacaoField == null || 
                            this.dataHoraInternacaoField == Util.EmptyDate)
                        {
                            _error = "Campo Obrigatório";
                        }
                        break;
                    case "diagnosticosSaidaInternacao":
                        if (diagnosticosSaidaInternacaoField == null)
                        {
                            _error = "Campo Obrigatório";
                        }
                        break;
                }

                return _error;
            }
        }

        #endregion
    }
}
